﻿//-----------------------------------------------------------------------
// <copyright file="MetricsReport.cs">(c) http://TfsBuildExtensions.codeplex.com/. This source is subject to the Microsoft Permissive License. See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx. All other rights reserved.</copyright>
//-----------------------------------------------------------------------
namespace TfsBuildExtensions.Activities.CodeMetrics.Extended
{
    using System.Linq;

    /// <summary>
    /// Manually added code to the autogenerated Member class, adding the MetricsInformation property.
    /// </summary>
    public partial class Member
    {
        /// <summary>
        /// Returns an  information string on the current metrics values for the method
        /// The format is a short hand:  MI = MaintainabilityIndex, CC = CyclomaticComplexity, CO = ClassCoupling and LOC = LinesOfCode
        /// </summary>
        public string MetricsInformation
        {
            get
            {
                var mi = this.Metrics.Single(m => m.Name == "MaintainabilityIndex");
                var cc = this.Metrics.Single(m => m.Name == "CyclomaticComplexity");
                var co = this.Metrics.Single(m => m.Name == "ClassCoupling");
                var lo = this.Metrics.Single(m => m.Name == "LinesOfCode");
                string result = string.Format("MI:{0} CC:{1} CO:{2} LOC:{3}", mi.Value, cc.Value, co.Value, lo.Value);
                return result;
            }
        }
    }
}